package com.artpri.dao.impl;

import java.util.List;

import org.hibernate.transform.Transformers;

import com.artpri.dao.GoodsAttrDao;
import com.artpri.model.GoodsAttr;
import com.artpri.model.vo.GoodsAttrVo;

/**
 * @author ZhangSi
 */
public class GoodsAttrDaoImpl extends HibernateDaoImpl<GoodsAttr> implements GoodsAttrDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<GoodsAttrVo> getGoodsAttrByGoods(int goodsNum) {
		return getSessionFactory().getCurrentSession()
				.createSQLQuery("select r.ga_id gaId, r.goods_num goodsNum, r.attr_id attrId, a.attr_name attrName, r.ga_value gaValue, r.ga_state gaState from goods_attr r, good_attribute a where r.goods_num=? and a.attr_id=r.attr_id")
				.setResultTransformer(Transformers.aliasToBean(GoodsAttrVo.class))
				.setInteger(0, goodsNum)
				.list();
	}

}
